<?php

/**
 * 订单管理
 */
namespace app\order\model;

use app\system\model\SystemModel;

class OrderModel extends SystemModel {

    protected $infoModel = [
        'pri' => 'order_id',
    ];

    public function loadList($where = array(), $limit = 0, $order = 'order_id desc') {
        $list = parent::loadList($where, $limit, $order);
        foreach($list as $key => $vo) {
            $list[$key]['status_data'] = target('order/Order', 'service')->getStatus($vo);
            $list[$key]['total_price'] = price_format($vo['delivery_price'] + $vo['order_price']);
            $list[$key]['order_action'] = target('order/Order', 'service')->getAction($vo);
            $list[$key]['status_data']['html'] = target('order/Order', 'service')->orderActionHtml($list[$key]);
        }
        return $list;
    }

    public function getWhereInfo($where) {
        $info = parent::getWhereInfo($where);
        $info['status_data'] = target('order/Order', 'service')->getStatus($info);
        $info['total_price'] = price_format($info['delivery_price'] + $info['order_price']);
        $info['order_action'] = target('order/Order', 'service')->getAction($info);
        return $info;
    }

    public function getInfo($id) {
        $where = [];
        $where['order_id'] = $id;
        return $this->getWhereInfo($where);
    }

    public function actionHtml($info) {

    }

}